using System.Collections.Generic;

namespace Voodoo.Sauce.Internal.Common.Utils
{
	public class QueryParameters
	{
		private string _baseUrl;

		private readonly Dictionary<string, object> _parameters;

		public QueryParameters(string baseUrl)
		{
			_baseUrl = baseUrl;
			_parameters = new Dictionary<string, object>();
		}

		public void Add(string key, object value)
		{
			if (!_parameters.ContainsKey(key))
			{
				_parameters.Add(key, value);
			}
			else
			{
				_parameters[key] = value;
			}
		}

		public string GetFormattedUrl()
		{
			List<string> list = new List<string>();
			foreach (KeyValuePair<string, object> parameter in _parameters)
			{
				list.Add($"{parameter.Key}={parameter.Value}");
			}
			string text = string.Join("&", list);
			return _baseUrl + "?" + text;
		}
	}
}
